<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2019-06-28
  Time: 9:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String pash = request.getContextPath();
    String basepash = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + pash + "/";
%>
<html>
<head>
    <base href="<%=basepash%>">
    <%@include file="/publs.jsp"%>
    <title>Title</title>
</head>
<body>
<div id="root">

    <Modal :mask-closable="false" title="添加仓库" v-model="showhidess" @on-ok="insert">
        <i-form :label-width="80">
            <form-item label="仓库名称">
                <i-input v-model="cangku.wname"></i-input>
            </form-item>
            <form-item label="仓库地址">
                <i-input v-model="cangku.wadd"></i-input>
            </form-item>
            <form-item label="仓库温度">
                <i-input v-model="wendu" type="number" style="width: 100px;margin-right: 10px;"></i-input>---
                <i-input v-model="wendus" type="number" style="width: 100px;margin-left: 10px;"></i-input>
            </form-item>
            <form-item label="状态">
                <i-select v-model="cangku.statics">
                    <i-option value="可用">可用</i-option>
                    <i-option value="停用">停用</i-option>
                </i-select>
            </form-item>
            <form-item label="仓库管理员">
               <i-select  v-model="cangku.adminid">
                   <i-option v-for="item in selectcangkuguanliyuan" :value="item.id">{{item.anames}}</i-option>
               </i-select>
            </form-item>
        </i-form>
    </Modal>

    <i-button @click="insertas" type="primary" style="margin-left: 50px;margin-top: 20px;">添加</i-button>

    <i-table :height="heights" style="margin-top:20px;margin-right: 50px;margin-left: 50px;" :data="datasasd" :columns="colunmsss" border>
        <template slot="caozuo" slot-scope="{row}">
            <i-button size="small" type="primary" @click="xiugai(row)">修改</i-button>
            <%--<i-button size="small" type="primary" @click="chakan(row)">查看</i-button>--%>
        </template>
    </i-table>
    <page :total="totals"  @on-change="onchenge" :page-Size="pageSize" show-sizer :page-size-opts="[4,8,12,14]" @on-page-size-change="onPageSizeChange"></page>


    <Modal :mask-closable="false" title="修改单位" v-model="showhidessss" @on-ok="update">
        <i-form :label-width="80">
            <form-item label="仓库名称">
                <i-input v-model="cangku.wname"></i-input>
            </form-item>
            <form-item label="仓库地址">
                <i-input v-model="cangku.wadd"></i-input>
            </form-item>
            <form-item label="仓库温度">
                <i-input v-model="cangku.templer"></i-input>
             </i-input>
            </form-item>
            <form-item label="状态">
                <i-select v-model="cangku.statics">
                    <i-option value="可用">可用</i-option>
                    <i-option value="停用">停用</i-option>
                </i-select>
            </form-item>
            <form-item label="仓库管理员">
                <i-select  v-model="cangku.adminid">
                    <i-option v-for="item in selectcangkuguanliyuan" :value="item.id">{{item.anames}}</i-option>
                </i-select>
            </form-item>
        </i-form>
    </Modal>

</div>
<script>
    let _this = null;
    new Vue({
        el:"#root",
        data:{
            datasasd:[],
            showhidessss:false,
            colunmsss:[
               {
                    title:"库存名称",
                    key:"wname"
                },{
                    title:"管理员",
                    key:"anames"
                },{
                    title:"地址",
                    key:"wadd"
                },{
                    title:"温度/°",
                    key:"templer"
                },{
                    title:"状态",
                    key:"statics"
                },{
                    title:"操作",
                    slot:"caozuo"
                }
            ],
            cangku:{},
            showhidess:false,
            selectcangkuguanliyuan:[],
            heights:0,
            name1:"",
            name2:"",
            name3:"",
            totals:0,
            pageNo:0,
            pageSize:8,
            wendu:"",
            wendus:""
        },
        methods:{
            onchenge(size){
                this.pageNo = size;
                this.select();
            },
            onPageSizeChange(size){
                this.pageSize = size;
                this.select();
            },
            insertas(){
                this.cangku = {};
                _this.showhidess = true;
            },
            insert(){
                this.cangku.templer = this.wendu+"°-"+this.wendus+"°";
                axios.post("/addcangku",this.cangku).then(({data})=>{
                    iview.Message.info(data.msg);
                    _this.cangku = {};
                    _this.select();
                });
            },
            select(){
                axios.get("/selectcangku?name1="+_this.name1+"&name2="+this.name2+"&name3="+this.name3+"&pageNo="+this.pageNo+"&pageSize="+this.pageSize).then(({data})=>{
                    _this.datasasd = data.obj.list;
                    _this.totals = data.obj.tatle;
                    _this.heights = data.obj.list.length * 48 + 40;
                });
            },
            selects(){
                axios.get("/selectcangkuguanliyuansss").then(({data})=>{
                    _this.selectcangkuguanliyuan = data.obj;
                });
            },
            xiugai(row){
                _this.showhidessss = true;
                Object.assign(this.cangku,row)
            },
            update(){
                axios.post("/updatecangku",this.cangku).then(({data})=>{
                    iview.Message.info(data.msg);
                    _this.danwei = {};
                    _this.select();
                });
            },
            chakan(row){

            }
        },
        mounted(){
            this.select();
            this.selects();
        },
        created(){
            _this = this;
        }
    })
</script>
</body>
</html>
